package com.hand.wfive.view.dialog;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.BottomPopupView;
import com.hand.wfive.R;
import com.hand.wfive.entity.FileModel;
import com.hand.wfive.entity.Params;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class MoreActionView extends BottomPopupView {
    private OnSelectCallBack onSelectCallBack;
    private FileModel model;

    public MoreActionView(@NonNull Context context, FileModel model, OnSelectCallBack onSelectCallBack) {
        super(context);
        this.onSelectCallBack = onSelectCallBack;
        this.model = model;
    }

    public interface OnSelectCallBack {
        void call(int position);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_more_action;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        ButterKnife.bind(this);
        if (Params.fileStatusSign.equals(model.getStatus()) && Params.fileTypeWord.equals(model.getType())) {
            findViewById(R.id.ll_to_down_phone).setVisibility(View.VISIBLE);
            findViewById(R.id.l_word_to_phone).setVisibility(View.VISIBLE);
        } else {
            findViewById(R.id.ll_to_down_phone).setVisibility(View.GONE);
            findViewById(R.id.l_word_to_phone).setVisibility(View.GONE);
        }

    }

    @OnClick({R.id.iv_close, R.id.iv_to_sign, R.id.iv_to_cloud,
            R.id.iv_to_phone, R.id.rl_to_share, R.id.ll_to_down_phone,
            R.id.rl_to_rename, R.id.rl_to_delete})
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.iv_to_sign: {
                if (onSelectCallBack != null)
                    onSelectCallBack.call(1);
            }
            break;
            case R.id.iv_to_cloud: {
                if (onSelectCallBack != null)
                    onSelectCallBack.call(2);
            }
            break;
            case R.id.iv_to_phone: {
                if (onSelectCallBack != null)
                    onSelectCallBack.call(3);
            }
            break;
            case R.id.rl_to_share: {
                if (onSelectCallBack != null)
                    onSelectCallBack.call(4);
            }
            break;
            case R.id.ll_to_down_phone: {
                if (onSelectCallBack != null)
                    onSelectCallBack.call(5);
            }
            break;
            case R.id.rl_to_rename: {
                if (onSelectCallBack != null)
                    onSelectCallBack.call(6);
            }
            break;
            case R.id.rl_to_delete: {
                if (onSelectCallBack != null)
                    onSelectCallBack.call(7);
            }
            break;

        }
        dismiss();
    }
}
